/*
 Use it if you like it
 @source http://purl.eligrey.com/github/canvas-toBlob.js/blob/master/canvas-toBlob.js  @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
(function(){function l(f){var a=[0,0,0],l=function(c,b){var e=f.match(c);null!=e&&(a[b]+=e.length,f=f.replace(c," "))};f=f.replace(/:not\(([^\)]*)\)/g,"     $1 ");f=f.replace(/{[^]*/gm," ");l(v,1);l(A,0);l(z,1);l(t,2);l(m,1);l(E,1);f=f.replace(/[\*\s\+>~]/g," ");f=f.replace(/[#\.]/g," ");l(g,2);return a.join("")}function w(f){var a={opts:f,FRAMERATE:30,MAX_VIRTUAL_PIXELS:3E4,log:function(a){}};1==a.opts.log&&"undefined"!=typeof console&&(a.log=function(a){console.log(a)});a.init=function(c){var b=
0;a.UniqueId=function(){b++;return"canvg"+b};a.Definitions={};a.Styles={};a.StylesSpecificity={};a.Animations=[];a.Images=[];a.ctx=c;a.ViewPort=new function(){this.viewPorts=[];this.Clear=function(){this.viewPorts=[]};this.SetCurrent=function(a,b){this.viewPorts.push({width:a,height:b})};this.RemoveCurrent=function(){this.viewPorts.pop()};this.Current=function(){return this.viewPorts[this.viewPorts.length-1]};this.width=function(){return this.Current().width};this.height=function(){return this.Current().height};
this.ComputeSize=function(a){return null!=a&&"number"==typeof a?a:"x"==a?this.width():"y"==a?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}};a.init();a.ImagesLoaded=function(){for(var c=0;c<a.Images.length;c++)if(!a.Images[c].loaded)return!1;return!0};a.trim=function(a){return a.replace(/^\s+|\s+$/g,"")};a.compressSpaces=function(a){return a.replace(/[\s\r\t\n]+/gm," ")};a.ajax=function(a){var b=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");
b.open("GET",a,!1);b.send(null);return b.responseText};a.parseXml=function(a){if("undefined"!=typeof Windows&&"undefined"!=typeof Windows.Data&&"undefined"!=typeof Windows.Data.Xml){var b=new Windows.Data.Xml.Dom.XmlDocument,e=new Windows.Data.Xml.Dom.XmlLoadSettings;e.prohibitDtd=!1;b.loadXml(a,e);return b}if(window.DOMParser)return(new DOMParser).parseFromString(a,"text/xml");a=a.replace(/<!DOCTYPE svg[^>]*>/,"");b=new ActiveXObject("Microsoft.XMLDOM");b.async="false";b.loadXML(a);return b};a.Property=
function(a,b){this.name=a;this.value=b};a.Property.prototype.getValue=function(){return this.value};a.Property.prototype.hasValue=function(){return null!=this.value&&""!==this.value};a.Property.prototype.numValue=function(){if(!this.hasValue())return 0;var a=parseFloat(this.value);(this.value+"").match(/%$/)&&(a/=100);return a};a.Property.prototype.valueOrDefault=function(a){return this.hasValue()?this.value:a};a.Property.prototype.numValueOrDefault=function(a){return this.hasValue()?this.numValue():
a};a.Property.prototype.addOpacity=function(c){var b=this.value;if(null!=c.value&&""!=c.value&&"string"==typeof this.value){var e=new RGBColor(this.value);e.ok&&(b="rgba("+e.r+", "+e.g+", "+e.b+", "+c.numValue()+")")}return new a.Property(this.name,b)};a.Property.prototype.getDefinition=function(){var c=this.value.match(/#([^\)'"]+)/);c&&(c=c[1]);c||(c=this.value);return a.Definitions[c]};a.Property.prototype.isUrlDefinition=function(){return 0==this.value.indexOf("url(")};a.Property.prototype.getFillStyleDefinition=
function(c,b){var e=this.getDefinition();if(null!=e&&e.createGradient)return e.createGradient(a.ctx,c,b);if(null!=e&&e.createPattern){if(e.getHrefAttribute().hasValue()){var d=e.attribute("patternTransform");e=e.getHrefAttribute().getDefinition();d.hasValue()&&(e.attribute("patternTransform",!0).value=d.value)}return e.createPattern(a.ctx,c)}return null};a.Property.prototype.getDPI=function(a){return 96};a.Property.prototype.getEM=function(c){var b=12,e=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);
e.hasValue()&&(b=e.toPixels(c));return b};a.Property.prototype.getUnits=function(){return(this.value+"").replace(/[0-9\.\-]/g,"")};a.Property.prototype.toPixels=function(c,b){if(!this.hasValue())return 0;var e=this.value+"";if(e.match(/em$/))return this.numValue()*this.getEM(c);if(e.match(/ex$/))return this.numValue()*this.getEM(c)/2;if(e.match(/px$/))return this.numValue();if(e.match(/pt$/))return this.numValue()*this.getDPI(c)*(1/72);if(e.match(/pc$/))return 15*this.numValue();if(e.match(/cm$/))return this.numValue()*
this.getDPI(c)/2.54;if(e.match(/mm$/))return this.numValue()*this.getDPI(c)/25.4;if(e.match(/in$/))return this.numValue()*this.getDPI(c);if(e.match(/%$/))return this.numValue()*a.ViewPort.ComputeSize(c);e=this.numValue();return b&&1>e?e*a.ViewPort.ComputeSize(c):e};a.Property.prototype.toMilliseconds=function(){if(!this.hasValue())return 0;var a=this.value+"";if(a.match(/s$/))return 1E3*this.numValue();a.match(/ms$/);return this.numValue()};a.Property.prototype.toRadians=function(){if(!this.hasValue())return 0;
var a=this.value+"";return a.match(/deg$/)?this.numValue()*(Math.PI/180):a.match(/grad$/)?this.numValue()*(Math.PI/200):a.match(/rad$/)?this.numValue():this.numValue()*(Math.PI/180)};var g={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};a.Property.prototype.toTextBaseline=function(){return this.hasValue()?
g[this.value]:null};a.Font=new function(){this.Styles="normal|italic|oblique|inherit";this.Variants="normal|small-caps|inherit";this.Weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit";this.CreateFont=function(b,e,d,c,k,h){h=null!=h?this.Parse(h):this.CreateFont("","","","","",a.ctx.font);return{fontFamily:k||h.fontFamily,fontSize:c||h.fontSize,fontStyle:b||h.fontStyle,fontWeight:d||h.fontWeight,fontVariant:e||h.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,
this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var c=this;this.Parse=function(b){var e={};b=a.trim(a.compressSpaces(b||"")).split(" ");for(var d=!1,q=!1,k=!1,h=!1,p="",y=0;y<b.length;y++)q||-1==c.Styles.indexOf(b[y])?h||-1==c.Variants.indexOf(b[y])?k||-1==c.Weights.indexOf(b[y])?d?"inherit"!=b[y]&&(p+=b[y]):("inherit"!=b[y]&&(e.fontSize=b[y].split("/")[0]),q=h=k=d=!0):("inherit"!=b[y]&&(e.fontWeight=b[y]),q=h=k=!0):("inherit"!=b[y]&&(e.fontVariant=b[y]),q=h=!0):("inherit"!=b[y]&&(e.fontStyle=
b[y]),q=!0);""!=p&&(e.fontFamily=p);return e}};a.ToNumberArray=function(c){c=a.trim(a.compressSpaces((c||"").replace(/,/g," "))).split(" ");for(var b=0;b<c.length;b++)c[b]=parseFloat(c[b]);return c};a.Point=function(a,b){this.x=a;this.y=b};a.Point.prototype.angleTo=function(a){return Math.atan2(a.y-this.y,a.x-this.x)};a.Point.prototype.applyTransform=function(a){var b=this.x*a[1]+this.y*a[3]+a[5];this.x=this.x*a[0]+this.y*a[2]+a[4];this.y=b};a.CreatePoint=function(c){c=a.ToNumberArray(c);return new a.Point(c[0],
c[1])};a.CreatePath=function(c){c=a.ToNumberArray(c);for(var b=[],e=0;e<c.length;e+=2)b.push(new a.Point(c[e],c[e+1]));return b};a.BoundingBox=function(a,b,e,d){this.y2=this.x2=this.y1=this.x1=Number.NaN;this.x=function(){return this.x1};this.y=function(){return this.y1};this.width=function(){return this.x2-this.x1};this.height=function(){return this.y2-this.y1};this.addPoint=function(a,b){if(null!=a){if(isNaN(this.x1)||isNaN(this.x2))this.x2=this.x1=a;a<this.x1&&(this.x1=a);a>this.x2&&(this.x2=a)}if(null!=
b){if(isNaN(this.y1)||isNaN(this.y2))this.y2=this.y1=b;b<this.y1&&(this.y1=b);b>this.y2&&(this.y2=b)}};this.addX=function(a){this.addPoint(a,null)};this.addY=function(a){this.addPoint(null,a)};this.addBoundingBox=function(a){this.addPoint(a.x1,a.y1);this.addPoint(a.x2,a.y2)};this.addQuadraticCurve=function(a,b,e,d,c,f){e=a+2/3*(e-a);d=b+2/3*(d-b);this.addBezierCurve(a,b,e,e+1/3*(c-a),d,d+1/3*(f-b),c,f)};this.addBezierCurve=function(a,b,e,d,c,f,g,m){var k=[a,b],h=[e,d],q=[c,f],p=[g,m];this.addPoint(k[0],
k[1]);this.addPoint(p[0],p[1]);for(i=0;1>=i;i++)a=function(a){return Math.pow(1-a,3)*k[i]+3*Math.pow(1-a,2)*a*h[i]+3*(1-a)*Math.pow(a,2)*q[i]+Math.pow(a,3)*p[i]},b=6*k[i]-12*h[i]+6*q[i],e=-3*k[i]+9*h[i]-9*q[i]+3*p[i],d=3*h[i]-3*k[i],0==e?0!=b&&(b=-d/b,0<b&&1>b&&(0==i&&this.addX(a(b)),1==i&&this.addY(a(b)))):(d=Math.pow(b,2)-4*d*e,0>d||(c=(-b+Math.sqrt(d))/(2*e),0<c&&1>c&&(0==i&&this.addX(a(c)),1==i&&this.addY(a(c))),b=(-b-Math.sqrt(d))/(2*e),0<b&&1>b&&(0==i&&this.addX(a(b)),1==i&&this.addY(a(b)))))};
this.isPointInBox=function(a,b){return this.x1<=a&&a<=this.x2&&this.y1<=b&&b<=this.y2};this.addPoint(a,b);this.addPoint(e,d)};a.Transform=function(c){var b=this;this.Type={};this.Type.translate=function(b){this.p=a.CreatePoint(b);this.apply=function(a){a.translate(this.p.x||0,this.p.y||0)};this.unapply=function(a){a.translate(-1*this.p.x||0,-1*this.p.y||0)};this.applyToPoint=function(a){a.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}};this.Type.rotate=function(b){b=a.ToNumberArray(b);this.angle=
new a.Property("angle",b[0]);this.cx=b[1]||0;this.cy=b[2]||0;this.apply=function(a){a.translate(this.cx,this.cy);a.rotate(this.angle.toRadians());a.translate(-this.cx,-this.cy)};this.unapply=function(a){a.translate(this.cx,this.cy);a.rotate(-1*this.angle.toRadians());a.translate(-this.cx,-this.cy)};this.applyToPoint=function(a){var b=this.angle.toRadians();a.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]);a.applyTransform([Math.cos(b),Math.sin(b),-Math.sin(b),Math.cos(b),0,0]);a.applyTransform([1,
0,0,1,-this.p.x||0,-this.p.y||0])}};this.Type.scale=function(b){this.p=a.CreatePoint(b);this.apply=function(a){a.scale(this.p.x||1,this.p.y||this.p.x||1)};this.unapply=function(a){a.scale(1/this.p.x||1,1/this.p.y||this.p.x||1)};this.applyToPoint=function(a){a.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}};this.Type.matrix=function(b){this.m=a.ToNumberArray(b);this.apply=function(a){a.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])};this.unapply=function(a){var b=this.m[0],
e=this.m[2],d=this.m[4],c=this.m[1],k=this.m[3],q=this.m[5],h=1/(b*(1*k-0*q)-e*(1*c-0*q)+d*(0*c-0*k));a.transform(h*(1*k-0*q),h*(0*q-1*c),h*(0*d-1*e),h*(1*b-0*d),h*(e*q-d*k),h*(d*c-b*q))};this.applyToPoint=function(a){a.applyTransform(this.m)}};this.Type.SkewBase=function(e){this.base=b.Type.matrix;this.base(e);this.angle=new a.Property("angle",e)};this.Type.SkewBase.prototype=new this.Type.matrix;this.Type.skewX=function(a){this.base=b.Type.SkewBase;this.base(a);this.m=[1,0,Math.tan(this.angle.toRadians()),
1,0,0]};this.Type.skewX.prototype=new this.Type.SkewBase;this.Type.skewY=function(a){this.base=b.Type.SkewBase;this.base(a);this.m=[1,Math.tan(this.angle.toRadians()),0,1,0,0]};this.Type.skewY.prototype=new this.Type.SkewBase;this.transforms=[];this.apply=function(a){for(var b=0;b<this.transforms.length;b++)this.transforms[b].apply(a)};this.unapply=function(a){for(var b=this.transforms.length-1;0<=b;b--)this.transforms[b].unapply(a)};this.applyToPoint=function(a){for(var b=0;b<this.transforms.length;b++)this.transforms[b].applyToPoint(a)};
c=a.trim(a.compressSpaces(c)).replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/);for(var e=0;e<c.length;e++){var d=a.trim(c[e].split("(")[0]),q=c[e].split("(")[1].replace(")","");q=new this.Type[d](q);q.type=d;this.transforms.push(q)}};a.AspectRatio=function(c,b,e,d,q,k,h,p,y,f){b=a.compressSpaces(b);b=b.replace(/^defer\s/,"");var g=b.split(" ")[0]||"xMidYMid";b=b.split(" ")[1]||"meet";var F=e/d,m=q/k,r=Math.min(F,m),l=Math.max(F,m);"meet"==b&&(d*=r,k*=r);"slice"==b&&
(d*=l,k*=l);y=new a.Property("refX",y);f=new a.Property("refY",f);y.hasValue()&&f.hasValue()?c.translate(-r*y.toPixels("x"),-r*f.toPixels("y")):(g.match(/^xMid/)&&("meet"==b&&r==m||"slice"==b&&l==m)&&c.translate(e/2-d/2,0),g.match(/YMid$/)&&("meet"==b&&r==F||"slice"==b&&l==F)&&c.translate(0,q/2-k/2),g.match(/^xMax/)&&("meet"==b&&r==m||"slice"==b&&l==m)&&c.translate(e-d,0),g.match(/YMax$/)&&("meet"==b&&r==F||"slice"==b&&l==F)&&c.translate(0,q-k));"none"==g?c.scale(F,m):"meet"==b?c.scale(r,r):"slice"==
b&&c.scale(l,l);c.translate(null==h?0:-h,null==p?0:-p)};a.Element={};a.EmptyProperty=new a.Property("EMPTY","");a.Element.ElementBase=function(c){this.attributes={};this.styles={};this.stylesSpecificity={};this.children=[];this.attribute=function(b,e){var d=this.attributes[b];if(null!=d)return d;1==e&&(d=new a.Property(b,""),this.attributes[b]=d);return d||a.EmptyProperty};this.getHrefAttribute=function(){for(var b in this.attributes)if("href"==b||b.match(/:href$/))return this.attributes[b];return a.EmptyProperty};
this.style=function(b,e,d){var c=this.styles[b];if(null!=c)return c;var k=this.attribute(b);if(null!=k&&k.hasValue())return this.styles[b]=k;if(1!=d&&(d=this.parent,null!=d&&(d=d.style(b),null!=d&&d.hasValue())))return d;1==e&&(c=new a.Property(b,""),this.styles[b]=c);return c||a.EmptyProperty};this.render=function(a){if("none"!=this.style("display").value&&"hidden"!=this.style("visibility").value){a.save();if(this.attribute("mask").hasValue()){var b=this.attribute("mask").getDefinition();null!=b&&
b.apply(a,this)}else this.style("filter").hasValue()?(b=this.style("filter").getDefinition(),null!=b&&b.apply(a,this)):(this.setContext(a),this.renderChildren(a),this.clearContext(a));a.restore()}};this.setContext=function(a){};this.clearContext=function(a){};this.renderChildren=function(a){for(var b=0;b<this.children.length;b++)this.children[b].render(a)};this.addChild=function(b,e){var d=b;e&&(d=a.CreateElement(b));d.parent=this;"title"!=d.type&&this.children.push(d)};this.addStylesFromStyleDefinition=
function(){for(var b in a.Styles)if("@"!=b[0]&&n(c,b)){var e=a.Styles[b],d=a.StylesSpecificity[b];if(null!=e)for(var q in e){var f=this.stylesSpecificity[q];"undefined"==typeof f&&(f="000");d>f&&(this.styles[q]=e[q],this.stylesSpecificity[q]=d)}}};if(null!=c&&1==c.nodeType){for(var b=0;b<c.attributes.length;b++){var e=c.attributes[b];this.attributes[e.nodeName]=new a.Property(e.nodeName,e.value)}this.addStylesFromStyleDefinition();if(this.attribute("style").hasValue())for(e=this.attribute("style").value.split(";"),
b=0;b<e.length;b++)if(""!=a.trim(e[b])){var d=e[b].split(":"),q=a.trim(d[0]);d=a.trim(d[1]);this.styles[q]=new a.Property(q,d)}this.attribute("id").hasValue()&&null==a.Definitions[this.attribute("id").value]&&(a.Definitions[this.attribute("id").value]=this);for(b=0;b<c.childNodes.length;b++)e=c.childNodes[b],1==e.nodeType&&this.addChild(e,!0),!this.captureTextNodes||3!=e.nodeType&&4!=e.nodeType||""!=a.compressSpaces(e.value||e.text||e.textContent||"")&&this.addChild(new a.Element.tspan(e),!1)}};a.Element.RenderedElementBase=
function(c){this.base=a.Element.ElementBase;this.base(c);this.setContext=function(b){if(this.style("fill").isUrlDefinition()){var e=this.style("fill").getFillStyleDefinition(this,this.style("fill-opacity"));null!=e&&(b.fillStyle=e)}else this.style("fill").hasValue()&&(e=this.style("fill"),"currentColor"==e.value&&(e.value=this.style("color").value),"inherit"!=e.value&&(b.fillStyle="none"==e.value?"rgba(0,0,0,0)":e.value));this.style("fill-opacity").hasValue()&&(e=new a.Property("fill",b.fillStyle),
e=e.addOpacity(this.style("fill-opacity")),b.fillStyle=e.value);this.style("stroke").isUrlDefinition()?(e=this.style("stroke").getFillStyleDefinition(this,this.style("stroke-opacity")),null!=e&&(b.strokeStyle=e)):this.style("stroke").hasValue()&&(e=this.style("stroke"),"currentColor"==e.value&&(e.value=this.style("color").value),"inherit"!=e.value&&(b.strokeStyle="none"==e.value?"rgba(0,0,0,0)":e.value));this.style("stroke-opacity").hasValue()&&(e=new a.Property("stroke",b.strokeStyle),e=e.addOpacity(this.style("stroke-opacity")),
b.strokeStyle=e.value);this.style("stroke-width").hasValue()&&(e=this.style("stroke-width").toPixels(),b.lineWidth=0==e?.001:e);this.style("stroke-linecap").hasValue()&&(b.lineCap=this.style("stroke-linecap").value);this.style("stroke-linejoin").hasValue()&&(b.lineJoin=this.style("stroke-linejoin").value);this.style("stroke-miterlimit").hasValue()&&(b.miterLimit=this.style("stroke-miterlimit").value);this.style("stroke-dasharray").hasValue()&&"none"!=this.style("stroke-dasharray").value&&(e=a.ToNumberArray(this.style("stroke-dasharray").value),
"undefined"!=typeof b.setLineDash?b.setLineDash(e):"undefined"!=typeof b.webkitLineDash?b.webkitLineDash=e:"undefined"==typeof b.mozDash||1==e.length&&0==e[0]||(b.mozDash=e),e=this.style("stroke-dashoffset").numValueOrDefault(1),"undefined"!=typeof b.lineDashOffset?b.lineDashOffset=e:"undefined"!=typeof b.webkitLineDashOffset?b.webkitLineDashOffset=e:"undefined"!=typeof b.mozDashOffset&&(b.mozDashOffset=e));"undefined"!=typeof b.font&&(b.font=a.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,
this.style("font-weight").value,this.style("font-size").hasValue()?this.style("font-size").toPixels()+"px":"",this.style("font-family").value).toString());this.style("transform",!1,!0).hasValue()&&(new a.Transform(this.style("transform",!1,!0).value)).apply(b);this.attribute("clip-path",!1,!0).hasValue()&&(e=this.attribute("clip-path",!1,!0).getDefinition(),null!=e&&e.apply(b));this.style("opacity").hasValue()&&(b.globalAlpha=this.style("opacity").numValue())}};a.Element.RenderedElementBase.prototype=
new a.Element.ElementBase;a.Element.PathElementBase=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.path=function(b){null!=b&&b.beginPath();return new a.BoundingBox};this.renderChildren=function(b){this.path(b);a.Mouse.checkPath(this,b);""!=b.fillStyle&&("inherit"!=this.style("fill-rule").valueOrDefault("inherit")?b.fill(this.style("fill-rule").value):b.fill());""!=b.strokeStyle&&b.stroke();var e=this.getMarkers();if(null!=e){if(this.style("marker-start").isUrlDefinition()){var d=
this.style("marker-start").getDefinition();d.render(b,e[0][0],e[0][1])}if(this.style("marker-mid").isUrlDefinition()){d=this.style("marker-mid").getDefinition();for(var c=1;c<e.length-1;c++)d.render(b,e[c][0],e[c][1])}this.style("marker-end").isUrlDefinition()&&(d=this.style("marker-end").getDefinition(),d.render(b,e[e.length-1][0],e[e.length-1][1]))}};this.getBoundingBox=function(){return this.path()};this.getMarkers=function(){return null}};a.Element.PathElementBase.prototype=new a.Element.RenderedElementBase;
a.Element.svg=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseClearContext=this.clearContext;this.clearContext=function(b){this.baseClearContext(b);a.ViewPort.RemoveCurrent()};this.baseSetContext=this.setContext;this.setContext=function(b){b.strokeStyle="rgba(0,0,0,0)";b.lineCap="butt";b.lineJoin="miter";b.miterLimit=4;"undefined"!=typeof b.font&&"undefined"!=typeof window.getComputedStyle&&(b.font=window.getComputedStyle(b.canvas).getPropertyValue("font"));this.baseSetContext(b);
this.attribute("x").hasValue()||(this.attribute("x",!0).value=0);this.attribute("y").hasValue()||(this.attribute("y",!0).value=0);b.translate(this.attribute("x").toPixels("x"),this.attribute("y").toPixels("y"));var e=a.ViewPort.width(),d=a.ViewPort.height();this.attribute("width").hasValue()||(this.attribute("width",!0).value="100%");this.attribute("height").hasValue()||(this.attribute("height",!0).value="100%");if("undefined"==typeof this.root){e=this.attribute("width").toPixels("x");d=this.attribute("height").toPixels("y");
var c=0,k=0;this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(c=-this.attribute("refX").toPixels("x"),k=-this.attribute("refY").toPixels("y"));"visible"!=this.attribute("overflow").valueOrDefault("hidden")&&(b.beginPath(),b.moveTo(c,k),b.lineTo(e,k),b.lineTo(e,d),b.lineTo(c,d),b.closePath(),b.clip())}a.ViewPort.SetCurrent(e,d);if(this.attribute("viewBox").hasValue()){c=a.ToNumberArray(this.attribute("viewBox").value);k=c[0];var h=c[1];e=c[2];d=c[3];a.AspectRatio(b,this.attribute("preserveAspectRatio").value,
a.ViewPort.width(),e,a.ViewPort.height(),d,k,h,this.attribute("refX").value,this.attribute("refY").value);a.ViewPort.RemoveCurrent();a.ViewPort.SetCurrent(c[2],c[3])}}};a.Element.svg.prototype=new a.Element.RenderedElementBase;a.Element.rect=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(b){var e=this.attribute("x").toPixels("x"),d=this.attribute("y").toPixels("y"),c=this.attribute("width").toPixels("x"),k=this.attribute("height").toPixels("y"),h=this.attribute("rx").toPixels("x"),
p=this.attribute("ry").toPixels("y");this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&(p=h);this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(h=p);h=Math.min(h,c/2);p=Math.min(p,k/2);null!=b&&(b.beginPath(),b.moveTo(e+h,d),b.lineTo(e+c-h,d),b.quadraticCurveTo(e+c,d,e+c,d+p),b.lineTo(e+c,d+k-p),b.quadraticCurveTo(e+c,d+k,e+c-h,d+k),b.lineTo(e+h,d+k),b.quadraticCurveTo(e,d+k,e,d+k-p),b.lineTo(e,d+p),b.quadraticCurveTo(e,d,e+h,d),b.closePath());return new a.BoundingBox(e,
d,e+c,d+k)}};a.Element.rect.prototype=new a.Element.PathElementBase;a.Element.circle=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(b){var e=this.attribute("cx").toPixels("x"),d=this.attribute("cy").toPixels("y"),c=this.attribute("r").toPixels();null!=b&&(b.beginPath(),b.arc(e,d,c,0,2*Math.PI,!0),b.closePath());return new a.BoundingBox(e-c,d-c,e+c,d+c)}};a.Element.circle.prototype=new a.Element.PathElementBase;a.Element.ellipse=function(c){this.base=a.Element.PathElementBase;
this.base(c);this.path=function(b){var e=(Math.sqrt(2)-1)/3*4,d=this.attribute("rx").toPixels("x"),c=this.attribute("ry").toPixels("y"),k=this.attribute("cx").toPixels("x"),h=this.attribute("cy").toPixels("y");null!=b&&(b.beginPath(),b.moveTo(k,h-c),b.bezierCurveTo(k+e*d,h-c,k+d,h-e*c,k+d,h),b.bezierCurveTo(k+d,h+e*c,k+e*d,h+c,k,h+c),b.bezierCurveTo(k-e*d,h+c,k-d,h+e*c,k-d,h),b.bezierCurveTo(k-d,h-e*c,k-e*d,h-c,k,h-c),b.closePath());return new a.BoundingBox(k-d,h-c,k+d,h+c)}};a.Element.ellipse.prototype=
new a.Element.PathElementBase;a.Element.line=function(c){this.base=a.Element.PathElementBase;this.base(c);this.getPoints=function(){return[new a.Point(this.attribute("x1").toPixels("x"),this.attribute("y1").toPixels("y")),new a.Point(this.attribute("x2").toPixels("x"),this.attribute("y2").toPixels("y"))]};this.path=function(b){var e=this.getPoints();null!=b&&(b.beginPath(),b.moveTo(e[0].x,e[0].y),b.lineTo(e[1].x,e[1].y));return new a.BoundingBox(e[0].x,e[0].y,e[1].x,e[1].y)};this.getMarkers=function(){var a=
this.getPoints(),e=a[0].angleTo(a[1]);return[[a[0],e],[a[1],e]]}};a.Element.line.prototype=new a.Element.PathElementBase;a.Element.polyline=function(c){this.base=a.Element.PathElementBase;this.base(c);this.points=a.CreatePath(this.attribute("points").value);this.path=function(b){var e=new a.BoundingBox(this.points[0].x,this.points[0].y);null!=b&&(b.beginPath(),b.moveTo(this.points[0].x,this.points[0].y));for(var d=1;d<this.points.length;d++)e.addPoint(this.points[d].x,this.points[d].y),null!=b&&b.lineTo(this.points[d].x,
this.points[d].y);return e};this.getMarkers=function(){for(var a=[],e=0;e<this.points.length-1;e++)a.push([this.points[e],this.points[e].angleTo(this.points[e+1])]);a.push([this.points[this.points.length-1],a[a.length-1][1]]);return a}};a.Element.polyline.prototype=new a.Element.PathElementBase;a.Element.polygon=function(c){this.base=a.Element.polyline;this.base(c);this.basePath=this.path;this.path=function(a){var b=this.basePath(a);null!=a&&(a.lineTo(this.points[0].x,this.points[0].y),a.closePath());
return b}};a.Element.polygon.prototype=new a.Element.polyline;a.Element.path=function(c){this.base=a.Element.PathElementBase;this.base(c);c=this.attribute("d").value;c=c.replace(/,/gm," ");for(var b=0;2>b;b++)c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");c=c.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([0-9])([+\-])/gm,"$1 $2");for(b=0;2>b;b++)c=c.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");c=c.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 ");c=a.compressSpaces(c);
c=a.trim(c);this.PathParser=new function(b){this.tokens=b.split(" ");this.reset=function(){this.i=-1;this.previousCommand=this.command="";this.start=new a.Point(0,0);this.control=new a.Point(0,0);this.current=new a.Point(0,0);this.points=[];this.angles=[]};this.isEnd=function(){return this.i>=this.tokens.length-1};this.isCommandOrEnd=function(){return this.isEnd()?!0:null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)};this.isRelativeCommand=function(){switch(this.command){case "m":case "l":case "h":case "v":case "c":case "s":case "q":case "t":case "a":case "z":return!0}return!1};
this.getToken=function(){this.i++;return this.tokens[this.i]};this.getScalar=function(){return parseFloat(this.getToken())};this.nextCommand=function(){this.previousCommand=this.command;this.command=this.getToken()};this.getPoint=function(){var b=new a.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(b)};this.getAsControlPoint=function(){var a=this.getPoint();return this.control=a};this.getAsCurrentPoint=function(){var a=this.getPoint();return this.current=a};this.getReflectedControlPoint=
function(){return"c"!=this.previousCommand.toLowerCase()&&"s"!=this.previousCommand.toLowerCase()&&"q"!=this.previousCommand.toLowerCase()&&"t"!=this.previousCommand.toLowerCase()?this.current:new a.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)};this.makeAbsolute=function(a){this.isRelativeCommand()&&(a.x+=this.current.x,a.y+=this.current.y);return a};this.addMarker=function(a,b,e){null!=e&&0<this.angles.length&&null==this.angles[this.angles.length-1]&&(this.angles[this.angles.length-
1]=this.points[this.points.length-1].angleTo(e));this.addMarkerAngle(a,null==b?null:b.angleTo(a))};this.addMarkerAngle=function(a,b){this.points.push(a);this.angles.push(b)};this.getMarkerPoints=function(){return this.points};this.getMarkerAngles=function(){for(var a=0;a<this.angles.length;a++)if(null==this.angles[a])for(var b=a+1;b<this.angles.length;b++)if(null!=this.angles[b]){this.angles[a]=this.angles[b];break}return this.angles}}(c);this.path=function(b){var d=this.PathParser;d.reset();var e=
new a.BoundingBox;for(null!=b&&b.beginPath();!d.isEnd();)switch(d.nextCommand(),d.command){case "M":case "m":var c=d.getAsCurrentPoint();d.addMarker(c);e.addPoint(c.x,c.y);null!=b&&b.moveTo(c.x,c.y);for(d.start=d.current;!d.isCommandOrEnd();)c=d.getAsCurrentPoint(),d.addMarker(c,d.start),e.addPoint(c.x,c.y),null!=b&&b.lineTo(c.x,c.y);break;case "L":case "l":for(;!d.isCommandOrEnd();){var h=d.current;c=d.getAsCurrentPoint();d.addMarker(c,h);e.addPoint(c.x,c.y);null!=b&&b.lineTo(c.x,c.y)}break;case "H":case "h":for(;!d.isCommandOrEnd();)c=
new a.Point((d.isRelativeCommand()?d.current.x:0)+d.getScalar(),d.current.y),d.addMarker(c,d.current),d.current=c,e.addPoint(d.current.x,d.current.y),null!=b&&b.lineTo(d.current.x,d.current.y);break;case "V":case "v":for(;!d.isCommandOrEnd();)c=new a.Point(d.current.x,(d.isRelativeCommand()?d.current.y:0)+d.getScalar()),d.addMarker(c,d.current),d.current=c,e.addPoint(d.current.x,d.current.y),null!=b&&b.lineTo(d.current.x,d.current.y);break;case "C":case "c":for(;!d.isCommandOrEnd();){var p=d.current;
h=d.getPoint();var f=d.getAsControlPoint();c=d.getAsCurrentPoint();d.addMarker(c,f,h);e.addBezierCurve(p.x,p.y,h.x,h.y,f.x,f.y,c.x,c.y);null!=b&&b.bezierCurveTo(h.x,h.y,f.x,f.y,c.x,c.y)}break;case "S":case "s":for(;!d.isCommandOrEnd();)p=d.current,h=d.getReflectedControlPoint(),f=d.getAsControlPoint(),c=d.getAsCurrentPoint(),d.addMarker(c,f,h),e.addBezierCurve(p.x,p.y,h.x,h.y,f.x,f.y,c.x,c.y),null!=b&&b.bezierCurveTo(h.x,h.y,f.x,f.y,c.x,c.y);break;case "Q":case "q":for(;!d.isCommandOrEnd();)p=d.current,
f=d.getAsControlPoint(),c=d.getAsCurrentPoint(),d.addMarker(c,f,f),e.addQuadraticCurve(p.x,p.y,f.x,f.y,c.x,c.y),null!=b&&b.quadraticCurveTo(f.x,f.y,c.x,c.y);break;case "T":case "t":for(;!d.isCommandOrEnd();)p=d.current,f=d.getReflectedControlPoint(),d.control=f,c=d.getAsCurrentPoint(),d.addMarker(c,f,f),e.addQuadraticCurve(p.x,p.y,f.x,f.y,c.x,c.y),null!=b&&b.quadraticCurveTo(f.x,f.y,c.x,c.y);break;case "A":case "a":for(;!d.isCommandOrEnd();){p=d.current;var g=d.getScalar(),m=d.getScalar();h=d.getScalar()*
(Math.PI/180);var l=d.getScalar();f=d.getScalar();c=d.getAsCurrentPoint();var n=new a.Point(Math.cos(h)*(p.x-c.x)/2+Math.sin(h)*(p.y-c.y)/2,-Math.sin(h)*(p.x-c.x)/2+Math.cos(h)*(p.y-c.y)/2),r=Math.pow(n.x,2)/Math.pow(g,2)+Math.pow(n.y,2)/Math.pow(m,2);1<r&&(g*=Math.sqrt(r),m*=Math.sqrt(r));l=(l==f?-1:1)*Math.sqrt((Math.pow(g,2)*Math.pow(m,2)-Math.pow(g,2)*Math.pow(n.y,2)-Math.pow(m,2)*Math.pow(n.x,2))/(Math.pow(g,2)*Math.pow(n.y,2)+Math.pow(m,2)*Math.pow(n.x,2)));isNaN(l)&&(l=0);var t=new a.Point(l*
g*n.y/m,l*-m*n.x/g);p=new a.Point((p.x+c.x)/2+Math.cos(h)*t.x-Math.sin(h)*t.y,(p.y+c.y)/2+Math.sin(h)*t.x+Math.cos(h)*t.y);var x=function(a,b){return(a[0]*b[0]+a[1]*b[1])/(Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2))*Math.sqrt(Math.pow(b[0],2)+Math.pow(b[1],2)))},u=function(a,b){return(a[0]*b[1]<a[1]*b[0]?-1:1)*Math.acos(x(a,b))};l=u([1,0],[(n.x-t.x)/g,(n.y-t.y)/m]);r=[(n.x-t.x)/g,(n.y-t.y)/m];t=[(-n.x-t.x)/g,(-n.y-t.y)/m];n=u(r,t);-1>=x(r,t)&&(n=Math.PI);1<=x(r,t)&&(n=0);r=1-f?1:-1;t=l+n/2*r;u=new a.Point(p.x+
g*Math.cos(t),p.y+m*Math.sin(t));d.addMarkerAngle(u,t-r*Math.PI/2);d.addMarkerAngle(c,t-r*Math.PI);e.addPoint(c.x,c.y);null!=b&&(x=g>m?g:m,c=g>m?1:g/m,g=g>m?m/g:1,b.translate(p.x,p.y),b.rotate(h),b.scale(c,g),b.arc(0,0,x,l,l+n,1-f),b.scale(1/c,1/g),b.rotate(-h),b.translate(-p.x,-p.y))}break;case "Z":case "z":null!=b&&b.closePath(),d.current=d.start}return e};this.getMarkers=function(){for(var a=this.PathParser.getMarkerPoints(),b=this.PathParser.getMarkerAngles(),c=[],k=0;k<a.length;k++)c.push([a[k],
b[k]]);return c}};a.Element.path.prototype=new a.Element.PathElementBase;a.Element.pattern=function(c){this.base=a.Element.ElementBase;this.base(c);this.createPattern=function(b,c){var e=this.attribute("width").toPixels("x",!0),q=this.attribute("height").toPixels("y",!0),k=new a.Element.svg;k.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);k.attributes.width=new a.Property("width",e+"px");k.attributes.height=new a.Property("height",q+"px");k.attributes.transform=new a.Property("transform",
this.attribute("patternTransform").value);k.children=this.children;var h=document.createElement("canvas");h.width=e;h.height=q;e=h.getContext("2d");this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&e.translate(this.attribute("x").toPixels("x",!0),this.attribute("y").toPixels("y",!0));for(q=-1;1>=q;q++)for(var f=-1;1>=f;f++)e.save(),k.attributes.x=new a.Property("x",q*h.width),k.attributes.y=new a.Property("y",f*h.height),k.render(e),e.restore();return b.createPattern(h,"repeat")}};a.Element.pattern.prototype=
new a.Element.ElementBase;a.Element.marker=function(c){this.base=a.Element.ElementBase;this.base(c);this.baseRender=this.render;this.render=function(b,c,d){b.translate(c.x,c.y);"auto"==this.attribute("orient").valueOrDefault("auto")&&b.rotate(d);"strokeWidth"==this.attribute("markerUnits").valueOrDefault("strokeWidth")&&b.scale(b.lineWidth,b.lineWidth);b.save();var e=new a.Element.svg;e.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);e.attributes.refX=new a.Property("refX",
this.attribute("refX").value);e.attributes.refY=new a.Property("refY",this.attribute("refY").value);e.attributes.width=new a.Property("width",this.attribute("markerWidth").value);e.attributes.height=new a.Property("height",this.attribute("markerHeight").value);e.attributes.fill=new a.Property("fill",this.attribute("fill").valueOrDefault("black"));e.attributes.stroke=new a.Property("stroke",this.attribute("stroke").valueOrDefault("none"));e.children=this.children;e.render(b);b.restore();"strokeWidth"==
this.attribute("markerUnits").valueOrDefault("strokeWidth")&&b.scale(1/b.lineWidth,1/b.lineWidth);"auto"==this.attribute("orient").valueOrDefault("auto")&&b.rotate(-d);b.translate(-c.x,-c.y)}};a.Element.marker.prototype=new a.Element.ElementBase;a.Element.defs=function(c){this.base=a.Element.ElementBase;this.base(c);this.render=function(a){}};a.Element.defs.prototype=new a.Element.ElementBase;a.Element.GradientBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.stops=[];for(c=0;c<this.children.length;c++){var b=
this.children[c];"stop"==b.type&&this.stops.push(b)}this.getGradient=function(){};this.gradientUnits=function(){return this.attribute("gradientUnits").valueOrDefault("objectBoundingBox")};this.attributesToInherit=["gradientUnits"];this.inheritStopContainer=function(a){for(var b=0;b<this.attributesToInherit.length;b++){var c=this.attributesToInherit[b];!this.attribute(c).hasValue()&&a.attribute(c).hasValue()&&(this.attribute(c,!0).value=a.attribute(c).value)}};this.createGradient=function(b,c,q){var e=
this;this.getHrefAttribute().hasValue()&&(e=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(e));var d=function(b){return q.hasValue()?(new a.Property("color",b)).addOpacity(q).value:b};b=this.getGradient(b,c);if(null==b)return d(e.stops[e.stops.length-1].color);for(c=0;c<e.stops.length;c++)b.addColorStop(e.stops[c].offset,d(e.stops[c].color));return this.attribute("gradientTransform").hasValue()?(e=a.ViewPort.viewPorts[0],d=new a.Element.rect,d.attributes.x=new a.Property("x",-a.MAX_VIRTUAL_PIXELS/
3),d.attributes.y=new a.Property("y",-a.MAX_VIRTUAL_PIXELS/3),d.attributes.width=new a.Property("width",a.MAX_VIRTUAL_PIXELS),d.attributes.height=new a.Property("height",a.MAX_VIRTUAL_PIXELS),c=new a.Element.g,c.attributes.transform=new a.Property("transform",this.attribute("gradientTransform").value),c.children=[d],d=new a.Element.svg,d.attributes.x=new a.Property("x",0),d.attributes.y=new a.Property("y",0),d.attributes.width=new a.Property("width",e.width),d.attributes.height=new a.Property("height",
e.height),d.children=[c],c=document.createElement("canvas"),c.width=e.width,c.height=e.height,e=c.getContext("2d"),e.fillStyle=b,d.render(e),e.createPattern(c,"no-repeat")):b}};a.Element.GradientBase.prototype=new a.Element.ElementBase;a.Element.linearGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.attributesToInherit.push("x1");this.attributesToInherit.push("y1");this.attributesToInherit.push("x2");this.attributesToInherit.push("y2");this.getGradient=function(a,c){var b="objectBoundingBox"==
this.gradientUnits()?c.getBoundingBox():null;this.attribute("x1").hasValue()||this.attribute("y1").hasValue()||this.attribute("x2").hasValue()||this.attribute("y2").hasValue()||(this.attribute("x1",!0).value=0,this.attribute("y1",!0).value=0,this.attribute("x2",!0).value=1,this.attribute("y2",!0).value=0);var e="objectBoundingBox"==this.gradientUnits()?b.x()+b.width()*this.attribute("x1").numValue():this.attribute("x1").toPixels("x"),k="objectBoundingBox"==this.gradientUnits()?b.y()+b.height()*this.attribute("y1").numValue():
this.attribute("y1").toPixels("y"),h="objectBoundingBox"==this.gradientUnits()?b.x()+b.width()*this.attribute("x2").numValue():this.attribute("x2").toPixels("x");b="objectBoundingBox"==this.gradientUnits()?b.y()+b.height()*this.attribute("y2").numValue():this.attribute("y2").toPixels("y");return e==h&&k==b?null:a.createLinearGradient(e,k,h,b)}};a.Element.linearGradient.prototype=new a.Element.GradientBase;a.Element.radialGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.attributesToInherit.push("cx");
this.attributesToInherit.push("cy");this.attributesToInherit.push("r");this.attributesToInherit.push("fx");this.attributesToInherit.push("fy");this.getGradient=function(a,c){var b=c.getBoundingBox();this.attribute("cx").hasValue()||(this.attribute("cx",!0).value="50%");this.attribute("cy").hasValue()||(this.attribute("cy",!0).value="50%");this.attribute("r").hasValue()||(this.attribute("r",!0).value="50%");var e="objectBoundingBox"==this.gradientUnits()?b.x()+b.width()*this.attribute("cx").numValue():
this.attribute("cx").toPixels("x"),k="objectBoundingBox"==this.gradientUnits()?b.y()+b.height()*this.attribute("cy").numValue():this.attribute("cy").toPixels("y"),h=e,f=k;this.attribute("fx").hasValue()&&(h="objectBoundingBox"==this.gradientUnits()?b.x()+b.width()*this.attribute("fx").numValue():this.attribute("fx").toPixels("x"));this.attribute("fy").hasValue()&&(f="objectBoundingBox"==this.gradientUnits()?b.y()+b.height()*this.attribute("fy").numValue():this.attribute("fy").toPixels("y"));b="objectBoundingBox"==
this.gradientUnits()?(b.width()+b.height())/2*this.attribute("r").numValue():this.attribute("r").toPixels();return a.createRadialGradient(h,f,0,e,k,b)}};a.Element.radialGradient.prototype=new a.Element.GradientBase;a.Element.stop=function(c){this.base=a.Element.ElementBase;this.base(c);this.offset=this.attribute("offset").numValue();0>this.offset&&(this.offset=0);1<this.offset&&(this.offset=1);c=this.style("stop-color",!0);""===c.value&&(c.value="#000");this.style("stop-opacity").hasValue()&&(c=c.addOpacity(this.style("stop-opacity")));
this.color=c.value};a.Element.stop.prototype=new a.Element.ElementBase;a.Element.AnimateBase=function(c){this.base=a.Element.ElementBase;this.base(c);a.Animations.push(this);this.duration=0;this.begin=this.attribute("begin").toMilliseconds();this.maxDuration=this.begin+this.attribute("dur").toMilliseconds();this.getProperty=function(){var a=this.attribute("attributeType").value,c=this.attribute("attributeName").value;return"CSS"==a?this.parent.style(c,!0):this.parent.attribute(c,!0)};this.initialValue=
null;this.initialUnits="";this.removed=!1;this.calcValue=function(){return""};this.update=function(a){null==this.initialValue&&(this.initialValue=this.getProperty().value,this.initialUnits=this.getProperty().getUnits());if(this.duration>this.maxDuration){if("indefinite"==this.attribute("repeatCount").value||"indefinite"==this.attribute("repeatDur").value)this.duration=0;else if("freeze"==this.attribute("fill").valueOrDefault("remove")&&!this.frozen)this.frozen=!0,this.parent.animationFrozen=!0,this.parent.animationFrozenValue=
this.getProperty().value;else if("remove"==this.attribute("fill").valueOrDefault("remove")&&!this.removed)return this.removed=!0,this.getProperty().value=this.parent.animationFrozen?this.parent.animationFrozenValue:this.initialValue,!0;return!1}this.duration+=a;a=!1;this.begin<this.duration&&(a=this.calcValue(),this.attribute("type").hasValue()&&(a=this.attribute("type").value+"("+a+")"),this.getProperty().value=a,a=!0);return a};this.from=this.attribute("from");this.to=this.attribute("to");this.values=
this.attribute("values");this.values.hasValue()&&(this.values.value=this.values.value.split(";"));this.progress=function(){var b={progress:(this.duration-this.begin)/(this.maxDuration-this.begin)};if(this.values.hasValue()){var c=b.progress*(this.values.value.length-1),d=Math.floor(c),q=Math.ceil(c);b.from=new a.Property("from",parseFloat(this.values.value[d]));b.to=new a.Property("to",parseFloat(this.values.value[q]));b.progress=(c-d)/(q-d)}else b.from=this.from,b.to=this.to;return b}};a.Element.AnimateBase.prototype=
new a.Element.ElementBase;a.Element.animate=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=this.progress();return a.from.numValue()+(a.to.numValue()-a.from.numValue())*a.progress+this.initialUnits}};a.Element.animate.prototype=new a.Element.AnimateBase;a.Element.animateColor=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=this.progress(),c=new RGBColor(a.from.value),d=new RGBColor(a.to.value);if(c.ok&&d.ok){var q=c.g+
(d.g-c.g)*a.progress,k=c.b+(d.b-c.b)*a.progress;return"rgb("+parseInt(c.r+(d.r-c.r)*a.progress,10)+","+parseInt(q,10)+","+parseInt(k,10)+")"}return this.attribute("from").value}};a.Element.animateColor.prototype=new a.Element.AnimateBase;a.Element.animateTransform=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){for(var b=this.progress(),c=a.ToNumberArray(b.from.value),d=a.ToNumberArray(b.to.value),q="",k=0;k<c.length;k++)q+=c[k]+(d[k]-c[k])*b.progress+" ";return q}};
a.Element.animateTransform.prototype=new a.Element.animate;a.Element.font=function(c){this.base=a.Element.ElementBase;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.isArabic=this.isRTL=!1;this.missingGlyph=this.fontFace=null;this.glyphs=[];for(c=0;c<this.children.length;c++){var b=this.children[c];"font-face"==b.type?(this.fontFace=b,b.style("font-family").hasValue()&&(a.Definitions[b.style("font-family").value]=this)):"missing-glyph"==b.type?this.missingGlyph=b:"glyph"==
b.type&&(""!=b.arabicForm?(this.isArabic=this.isRTL=!0,"undefined"==typeof this.glyphs[b.unicode]&&(this.glyphs[b.unicode]=[]),this.glyphs[b.unicode][b.arabicForm]=b):this.glyphs[b.unicode]=b)}};a.Element.font.prototype=new a.Element.ElementBase;a.Element.fontface=function(c){this.base=a.Element.ElementBase;this.base(c);this.ascent=this.attribute("ascent").value;this.descent=this.attribute("descent").value;this.unitsPerEm=this.attribute("units-per-em").numValue()};a.Element.fontface.prototype=new a.Element.ElementBase;
a.Element.missingglyph=function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=0};a.Element.missingglyph.prototype=new a.Element.path;a.Element.glyph=function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.unicode=this.attribute("unicode").value;this.arabicForm=this.attribute("arabic-form").value};a.Element.glyph.prototype=new a.Element.path;a.Element.text=function(c){this.captureTextNodes=!0;this.base=a.Element.RenderedElementBase;this.base(c);
this.baseSetContext=this.setContext;this.setContext=function(a){this.baseSetContext(a);var b=this.style("dominant-baseline").toTextBaseline();null==b&&(b=this.style("alignment-baseline").toTextBaseline());null!=b&&(a.textBaseline=b)};this.getBoundingBox=function(){var b=this.attribute("x").toPixels("x"),c=this.attribute("y").toPixels("y"),d=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize);return new a.BoundingBox(b,c-d,b+Math.floor(2*d/3)*this.children[0].getText().length,
c)};this.renderChildren=function(a){this.x=this.attribute("x").toPixels("x");this.y=this.attribute("y").toPixels("y");this.attribute("dx").hasValue()&&(this.x+=this.attribute("dx").toPixels("x"));this.attribute("dy").hasValue()&&(this.y+=this.attribute("dy").toPixels("y"));this.x+=this.getAnchorDelta(a,this,0);for(var b=0;b<this.children.length;b++)this.renderChild(a,this,b)};this.getAnchorDelta=function(a,c,d){var b=this.style("text-anchor").valueOrDefault("start");if("start"!=b){for(var e=0,h=d;h<
c.children.length;h++){var f=c.children[h];if(h>d&&f.attribute("x").hasValue())break;e+=f.measureTextRecursive(a)}return-1*("end"==b?e:e/2)}return 0};this.renderChild=function(a,c,d){var b=c.children[d];b.attribute("x").hasValue()?(b.x=b.attribute("x").toPixels("x")+c.getAnchorDelta(a,c,d),b.attribute("dx").hasValue()&&(b.x+=b.attribute("dx").toPixels("x"))):(b.attribute("dx").hasValue()&&(c.x+=b.attribute("dx").toPixels("x")),b.x=c.x);c.x=b.x+b.measureText(a);b.attribute("y").hasValue()?(b.y=b.attribute("y").toPixels("y"),
b.attribute("dy").hasValue()&&(b.y+=b.attribute("dy").toPixels("y"))):(b.attribute("dy").hasValue()&&(c.y+=b.attribute("dy").toPixels("y")),b.y=c.y);c.y=b.y;b.render(a);for(d=0;d<b.children.length;d++)c.renderChild(a,b,d)}};a.Element.text.prototype=new a.Element.RenderedElementBase;a.Element.TextElementBase=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getGlyph=function(a,c,d){var b=c[d],e=null;if(a.isArabic){var h="isolated";(0==d||" "==c[d-1])&&d<c.length-2&&" "!=c[d+1]&&
(h="terminal");0<d&&" "!=c[d-1]&&d<c.length-2&&" "!=c[d+1]&&(h="medial");0<d&&" "!=c[d-1]&&(d==c.length-1||" "==c[d+1])&&(h="initial");"undefined"!=typeof a.glyphs[b]&&(e=a.glyphs[b][h],null==e&&"glyph"==a.glyphs[b].type&&(e=a.glyphs[b]))}else e=a.glyphs[b];null==e&&(e=a.missingGlyph);return e};this.renderChildren=function(b){var c=this.parent.style("font-family").getDefinition();if(null!=c){var d=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize),f=this.parent.style("font-style").valueOrDefault(a.Font.Parse(a.ctx.font).fontStyle),
k=this.getText();c.isRTL&&(k=k.split("").reverse().join(""));for(var h=a.ToNumberArray(this.parent.attribute("dx").value),p=0;p<k.length;p++){var g=this.getGlyph(c,k,p),m=d/c.fontFace.unitsPerEm;b.translate(this.x,this.y);b.scale(m,-m);var l=b.lineWidth;b.lineWidth=b.lineWidth*c.fontFace.unitsPerEm/d;"italic"==f&&b.transform(1,0,.4,1,0,0);g.render(b);"italic"==f&&b.transform(1,0,-.4,1,0,0);b.lineWidth=l;b.scale(1/m,-1/m);b.translate(-this.x,-this.y);this.x+=d*(g.horizAdvX||c.horizAdvX)/c.fontFace.unitsPerEm;
"undefined"==typeof h[p]||isNaN(h[p])||(this.x+=h[p])}}else""!=b.fillStyle&&b.fillText(a.compressSpaces(this.getText()),this.x,this.y),""!=b.strokeStyle&&b.strokeText(a.compressSpaces(this.getText()),this.x,this.y)};this.getText=function(){};this.measureTextRecursive=function(a){for(var b=this.measureText(a),c=0;c<this.children.length;c++)b+=this.children[c].measureTextRecursive(a);return b};this.measureText=function(b){var c=this.parent.style("font-family").getDefinition();if(null!=c){b=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize);
var d=0,f=this.getText();c.isRTL&&(f=f.split("").reverse().join(""));for(var k=a.ToNumberArray(this.parent.attribute("dx").value),h=0;h<f.length;h++){var p=this.getGlyph(c,f,h);d+=(p.horizAdvX||c.horizAdvX)*b/c.fontFace.unitsPerEm;"undefined"==typeof k[h]||isNaN(k[h])||(d+=k[h])}return d}c=a.compressSpaces(this.getText());if(!b.measureText)return 10*c.length;b.save();this.setContext(b);c=b.measureText(c).width;b.restore();return c}};a.Element.TextElementBase.prototype=new a.Element.RenderedElementBase;
a.Element.tspan=function(c){this.captureTextNodes=!0;this.base=a.Element.TextElementBase;this.base(c);this.text=a.compressSpaces(c.value||c.text||c.textContent||"");this.getText=function(){return 0<this.children.length?"":this.text}};a.Element.tspan.prototype=new a.Element.TextElementBase;a.Element.tref=function(c){this.base=a.Element.TextElementBase;this.base(c);this.getText=function(){var a=this.getHrefAttribute().getDefinition();if(null!=a)return a.children[0].getText()}};a.Element.tref.prototype=
new a.Element.TextElementBase;a.Element.a=function(c){this.base=a.Element.TextElementBase;this.base(c);this.hasText=0<c.childNodes.length;for(var b=0;b<c.childNodes.length;b++)3!=c.childNodes[b].nodeType&&(this.hasText=!1);this.text=this.hasText?c.childNodes[0].value:"";this.getText=function(){return this.text};this.baseRenderChildren=this.renderChildren;this.renderChildren=function(b){if(this.hasText){this.baseRenderChildren(b);var c=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);a.Mouse.checkBoundingBox(this,
new a.BoundingBox(this.x,this.y-c.toPixels("y"),this.x+this.measureText(b),this.y))}else 0<this.children.length&&(c=new a.Element.g,c.children=this.children,c.parent=this,c.render(b))};this.onclick=function(){window.open(this.getHrefAttribute().value)};this.onmousemove=function(){a.ctx.canvas.style.cursor="pointer"}};a.Element.a.prototype=new a.Element.TextElementBase;a.Element.image=function(c){this.base=a.Element.RenderedElementBase;this.base(c);var b=this.getHrefAttribute().value;if(""!=b){var e=
b.match(/\.svg$/);a.Images.push(this);this.loaded=!1;if(e)this.img=a.ajax(b),this.loaded=!0;else{this.img=document.createElement("img");1==a.opts.useCORS&&(this.img.crossOrigin="Anonymous");var d=this;this.img.onload=function(){d.loaded=!0};this.img.onerror=function(){a.log('ERROR: image "'+b+'" not found');d.loaded=!0};this.img.src=b}this.renderChildren=function(b){var c=this.attribute("x").toPixels("x"),d=this.attribute("y").toPixels("y"),f=this.attribute("width").toPixels("x"),g=this.attribute("height").toPixels("y");
0!=f&&0!=g&&(b.save(),e?b.drawSvg(this.img,c,d,f,g):(b.translate(c,d),a.AspectRatio(b,this.attribute("preserveAspectRatio").value,f,this.img.width,g,this.img.height,0,0),b.drawImage(this.img,0,0)),b.restore())};this.getBoundingBox=function(){var b=this.attribute("x").toPixels("x"),c=this.attribute("y").toPixels("y"),e=this.attribute("width").toPixels("x"),d=this.attribute("height").toPixels("y");return new a.BoundingBox(b,c,b+e,c+d)}}};a.Element.image.prototype=new a.Element.RenderedElementBase;a.Element.g=
function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getBoundingBox=function(){for(var b=new a.BoundingBox,c=0;c<this.children.length;c++)b.addBoundingBox(this.children[c].getBoundingBox());return b}};a.Element.g.prototype=new a.Element.RenderedElementBase;a.Element.symbol=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.render=function(a){}};a.Element.symbol.prototype=new a.Element.RenderedElementBase;a.Element.style=function(c){this.base=a.Element.ElementBase;
this.base(c);for(var b="",e=0;e<c.childNodes.length;e++)b+=c.childNodes[e].data;b=b.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"");b=a.compressSpaces(b);c=b.split("}");for(e=0;e<c.length;e++)if(""!=a.trim(c[e])){var d=c[e].split("{");b=d[0].split(",");d=d[1].split(";");for(var f=0;f<b.length;f++){var k=a.trim(b[f]);if(""!=k){for(var h={},p=0;p<d.length;p++){var g=d[p].indexOf(":"),m=d[p].substr(0,g);g=d[p].substr(g+1,d[p].length-g);null!=m&&null!=g&&(h[a.trim(m)]=new a.Property(a.trim(m),
a.trim(g)))}a.Styles[k]=h;a.StylesSpecificity[k]=l(k);if("@font-face"==k)for(k=h["font-family"].value.replace(/"/g,""),h=h.src.value.split(","),p=0;p<h.length;p++)if(0<h[p].indexOf('format("svg")'))for(m=h[p].indexOf("url"),g=h[p].indexOf(")",m),m=h[p].substr(m+5,g-m-6),m=a.parseXml(a.ajax(m)).getElementsByTagName("font"),g=0;g<m.length;g++){var n=a.CreateElement(m[g]);a.Definitions[k]=n}}}}};a.Element.style.prototype=new a.Element.ElementBase;a.Element.use=function(c){this.base=a.Element.RenderedElementBase;
this.base(c);this.baseSetContext=this.setContext;this.setContext=function(a){this.baseSetContext(a);this.attribute("x").hasValue()&&a.translate(this.attribute("x").toPixels("x"),0);this.attribute("y").hasValue()&&a.translate(0,this.attribute("y").toPixels("y"))};var b=this.getHrefAttribute().getDefinition();this.path=function(a){null!=b&&b.path(a)};this.getBoundingBox=function(){if(null!=b)return b.getBoundingBox()};this.renderChildren=function(c){if(null!=b){var d=b;"symbol"==b.type&&(d=new a.Element.svg,
d.type="svg",d.attributes.viewBox=new a.Property("viewBox",b.attribute("viewBox").value),d.attributes.preserveAspectRatio=new a.Property("preserveAspectRatio",b.attribute("preserveAspectRatio").value),d.attributes.overflow=new a.Property("overflow",b.attribute("overflow").value),d.children=b.children);"svg"==d.type&&(this.attribute("width").hasValue()&&(d.attributes.width=new a.Property("width",this.attribute("width").value)),this.attribute("height").hasValue()&&(d.attributes.height=new a.Property("height",
this.attribute("height").value)));var e=d.parent;d.parent=null;d.render(c);d.parent=e}}};a.Element.use.prototype=new a.Element.RenderedElementBase;a.Element.mask=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(b,c){var d=this.attribute("x").toPixels("x"),e=this.attribute("y").toPixels("y"),f=this.attribute("width").toPixels("x"),h=this.attribute("height").toPixels("y");if(0==f&&0==h){h=new a.BoundingBox;for(d=0;d<this.children.length;d++)h.addBoundingBox(this.children[d].getBoundingBox());
d=Math.floor(h.x1);e=Math.floor(h.y1);f=Math.floor(h.width());h=Math.floor(h.height())}var g=c.attribute("mask").value;c.attribute("mask").value="";var m=document.createElement("canvas");m.width=d+f;m.height=e+h;var l=m.getContext("2d");this.renderChildren(l);var n=document.createElement("canvas");n.width=d+f;n.height=e+h;var t=n.getContext("2d");c.render(t);t.globalCompositeOperation="destination-in";t.fillStyle=l.createPattern(m,"no-repeat");t.fillRect(0,0,d+f,e+h);b.fillStyle=t.createPattern(n,
"no-repeat");b.fillRect(0,0,d+f,e+h);c.attribute("mask").value=g};this.render=function(a){}};a.Element.mask.prototype=new a.Element.ElementBase;a.Element.clipPath=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(b){var c=CanvasRenderingContext2D.prototype.beginPath;CanvasRenderingContext2D.prototype.beginPath=function(){};var d=CanvasRenderingContext2D.prototype.closePath;CanvasRenderingContext2D.prototype.closePath=function(){};c.call(b);for(var f=0;f<this.children.length;f++){var k=
this.children[f];if("undefined"!=typeof k.path){var h=null;k.style("transform",!1,!0).hasValue()&&(h=new a.Transform(k.style("transform",!1,!0).value),h.apply(b));k.path(b);CanvasRenderingContext2D.prototype.closePath=d;h&&h.unapply(b)}}d.call(b);b.clip();CanvasRenderingContext2D.prototype.beginPath=c;CanvasRenderingContext2D.prototype.closePath=d};this.render=function(a){}};a.Element.clipPath.prototype=new a.Element.ElementBase;a.Element.filter=function(c){this.base=a.Element.ElementBase;this.base(c);
this.apply=function(a,c){var b=c.getBoundingBox(),e=Math.floor(b.x1),f=Math.floor(b.y1),h=Math.floor(b.width());b=Math.floor(b.height());var g=c.style("filter").value;c.style("filter").value="";for(var m=0,l=0,n=0;n<this.children.length;n++){var t=this.children[n].extraFilterDistance||0;m=Math.max(m,t);l=Math.max(l,t)}t=document.createElement("canvas");t.width=h+2*m;t.height=b+2*l;var x=t.getContext("2d");x.translate(-e+m,-f+l);c.render(x);for(n=0;n<this.children.length;n++)"function"===typeof this.children[n].apply&&
this.children[n].apply(x,0,0,h+2*m,b+2*l);a.drawImage(t,0,0,h+2*m,b+2*l,e-m,f-l,h+2*m,b+2*l);c.style("filter",!0).value=g};this.render=function(a){}};a.Element.filter.prototype=new a.Element.ElementBase;a.Element.feMorphology=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,c,d,f,k){}};a.Element.feMorphology.prototype=new a.Element.ElementBase;a.Element.feComposite=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,c,d,f,k){}};a.Element.feComposite.prototype=
new a.Element.ElementBase;a.Element.feColorMatrix=function(c){function b(a,b){var c=e[a];return c*(0>c?b-255:b)}this.base=a.Element.ElementBase;this.base(c);var e=a.ToNumberArray(this.attribute("values").value);switch(this.attribute("type").valueOrDefault("matrix")){case "saturate":c=e[0];e=[.213+.787*c,.715-.715*c,.072-.072*c,0,0,.213-.213*c,.715+.285*c,.072-.072*c,0,0,.213-.213*c,.715-.715*c,.072+.928*c,0,0,0,0,0,1,0,0,0,0,0,1];break;case "hueRotate":var d=e[0]*Math.PI/180;c=function(a,b,c){return a+
Math.cos(d)*b+Math.sin(d)*c};e=[c(.213,.787,-.213),c(.715,-.715,-.715),c(.072,-.072,.928),0,0,c(.213,-.213,.143),c(.715,.285,.14),c(.072,-.072,-.283),0,0,c(.213,-.213,-.787),c(.715,-.715,.715),c(.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break;case "luminanceToAlpha":e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}this.apply=function(a,c,d,e,f){var h=a.getImageData(0,0,e,f);for(d=0;d<f;d++)for(c=0;c<e;c++){var g=h.data[d*e*4+4*c],k=h.data[d*e*4+4*c+1],m=h.data[d*e*4+4*c+2],p=h.data[d*
e*4+4*c+3],l=b(0,g)+b(1,k)+b(2,m)+b(3,p)+b(4,1);h.data[d*e*4+4*c]=l;l=b(5,g)+b(6,k)+b(7,m)+b(8,p)+b(9,1);h.data[d*e*4+4*c+1]=l;l=b(10,g)+b(11,k)+b(12,m)+b(13,p)+b(14,1);h.data[d*e*4+4*c+2]=l;g=b(15,g)+b(16,k)+b(17,m)+b(18,p)+b(19,1);h.data[d*e*4+4*c+3]=g}a.clearRect(0,0,e,f);a.putImageData(h,0,0)}};a.Element.feColorMatrix.prototype=new a.Element.ElementBase;a.Element.feGaussianBlur=function(c){this.base=a.Element.ElementBase;this.base(c);this.extraFilterDistance=this.blurRadius=Math.floor(this.attribute("stdDeviation").numValue());
this.apply=function(b,c,d,f,g){"undefined"==typeof stackBlurCanvasRGBA?a.log("ERROR: StackBlur.js must be included for blur to work"):(b.canvas.id=a.UniqueId(),b.canvas.style.display="none",document.body.appendChild(b.canvas),stackBlurCanvasRGBA(b.canvas.id,c,d,f,g,this.blurRadius),document.body.removeChild(b.canvas))}};a.Element.feGaussianBlur.prototype=new a.Element.ElementBase;a.Element.title=function(a){};a.Element.title.prototype=new a.Element.ElementBase;a.Element.desc=function(a){};a.Element.desc.prototype=
new a.Element.ElementBase;a.Element.MISSING=function(c){a.log("ERROR: Element '"+c.nodeName+"' not yet implemented.")};a.Element.MISSING.prototype=new a.Element.ElementBase;a.CreateElement=function(c){var b=c.nodeName.replace(/^[^:]+:/,"");b=b.replace(/\-/g,"");b="undefined"!=typeof a.Element[b]?new a.Element[b](c):new a.Element.MISSING(c);b.type=c.nodeName;return b};a.load=function(c,b){a.loadXml(c,a.ajax(b))};a.loadXml=function(c,b){a.loadXmlDoc(c,a.parseXml(b))};a.loadXmlDoc=function(c,b){a.init(c);
var e=function(a){for(var b=c.canvas;b;)a.x-=b.offsetLeft,a.y-=b.offsetTop,b=b.offsetParent;window.scrollX&&(a.x+=window.scrollX);window.scrollY&&(a.y+=window.scrollY);return a};1!=a.opts.ignoreMouse&&(c.canvas.onclick=function(b){b=e(new a.Point(null!=b?b.clientX:event.clientX,null!=b?b.clientY:event.clientY));a.Mouse.onclick(b.x,b.y)},c.canvas.onmousemove=function(b){b=e(new a.Point(null!=b?b.clientX:event.clientX,null!=b?b.clientY:event.clientY));a.Mouse.onmousemove(b.x,b.y)});var d=a.CreateElement(b.documentElement);
d.root=!0;d.addStylesFromStyleDefinition();var f=!0,g=function(){a.ViewPort.Clear();c.canvas.parentNode&&a.ViewPort.SetCurrent(c.canvas.parentNode.clientWidth,c.canvas.parentNode.clientHeight);1!=a.opts.ignoreDimensions&&(d.style("width").hasValue()&&(c.canvas.width=d.style("width").toPixels("x"),c.canvas.style.width=c.canvas.width+"px"),d.style("height").hasValue()&&(c.canvas.height=d.style("height").toPixels("y"),c.canvas.style.height=c.canvas.height+"px"));var e=c.canvas.clientWidth||c.canvas.width,
h=c.canvas.clientHeight||c.canvas.height;1==a.opts.ignoreDimensions&&d.style("width").hasValue()&&d.style("height").hasValue()&&(e=d.style("width").toPixels("x"),h=d.style("height").toPixels("y"));a.ViewPort.SetCurrent(e,h);null!=a.opts.offsetX&&(d.attribute("x",!0).value=a.opts.offsetX);null!=a.opts.offsetY&&(d.attribute("y",!0).value=a.opts.offsetY);if(null!=a.opts.scaleWidth||null!=a.opts.scaleHeight){var g=null,k=null,m=a.ToNumberArray(d.attribute("viewBox").value);null!=a.opts.scaleWidth&&(d.attribute("width").hasValue()?
g=d.attribute("width").toPixels("x")/a.opts.scaleWidth:isNaN(m[2])||(g=m[2]/a.opts.scaleWidth));null!=a.opts.scaleHeight&&(d.attribute("height").hasValue()?k=d.attribute("height").toPixels("y")/a.opts.scaleHeight:isNaN(m[3])||(k=m[3]/a.opts.scaleHeight));null==g&&(g=k);null==k&&(k=g);d.attribute("width",!0).value=a.opts.scaleWidth;d.attribute("height",!0).value=a.opts.scaleHeight;d.style("transform",!0,!0).value+=" scale("+1/g+","+1/k+")"}1!=a.opts.ignoreClear&&c.clearRect(0,0,e,h);d.render(c);f&&
(f=!1,"function"==typeof a.opts.renderCallback&&a.opts.renderCallback(b))},h=!0;a.ImagesLoaded()&&(h=!1,g());a.intervalID=setInterval(function(){var b=!1;h&&a.ImagesLoaded()&&(h=!1,b=!0);1!=a.opts.ignoreMouse&&(b|=a.Mouse.hasEvents());if(1!=a.opts.ignoreAnimation)for(var c=0;c<a.Animations.length;c++)b|=a.Animations[c].update(1E3/a.FRAMERATE);"function"==typeof a.opts.forceRedraw&&1==a.opts.forceRedraw()&&(b=!0);b&&(g(),a.Mouse.runEvents())},1E3/a.FRAMERATE)};a.stop=function(){a.intervalID&&clearInterval(a.intervalID)};
a.Mouse=new function(){this.events=[];this.hasEvents=function(){return 0!=this.events.length};this.onclick=function(a,b){this.events.push({type:"onclick",x:a,y:b,run:function(a){if(a.onclick)a.onclick()}})};this.onmousemove=function(a,b){this.events.push({type:"onmousemove",x:a,y:b,run:function(a){if(a.onmousemove)a.onmousemove()}})};this.eventElements=[];this.checkPath=function(a,b){for(var c=0;c<this.events.length;c++){var d=this.events[c];b.isPointInPath&&b.isPointInPath(d.x,d.y)&&(this.eventElements[c]=
a)}};this.checkBoundingBox=function(a,b){for(var c=0;c<this.events.length;c++){var d=this.events[c];b.isPointInBox(d.x,d.y)&&(this.eventElements[c]=a)}};this.runEvents=function(){a.ctx.canvas.style.cursor="";for(var c=0;c<this.events.length;c++)for(var b=this.events[c],e=this.eventElements[c];e;)b.run(e),e=e.parent;this.events=[];this.eventElements=[]}};return a}this.canvg=function(f,a,g){if(null==f&&null==a&&null==g)for(a=document.querySelectorAll("svg"),f=0;f<a.length;f++){g=a[f];var c=document.createElement("canvas");
c.width=g.clientWidth;c.height=g.clientHeight;g.parentNode.insertBefore(c,g);g.parentNode.removeChild(g);var b=document.createElement("div");b.appendChild(g);canvg(c,b.innerHTML)}else{"string"==typeof f&&(f=document.getElementById(f));null!=f.svg&&f.svg.stop();g=w(g||{});if(1!=f.childNodes.length||"OBJECT"!=f.childNodes[0].nodeName)f.svg=g;f=f.getContext("2d");"undefined"!=typeof a.documentElement?g.loadXmlDoc(f,a):"<"==a.substr(0,1)?g.loadXml(f,a):g.load(f,a)}};if("undefined"!=typeof Element.prototype.matches)var n=
function(f,a){return f.matches(a)};else if("undefined"!=typeof Element.prototype.webkitMatchesSelector)n=function(f,a){return f.webkitMatchesSelector(a)};else if("undefined"!=typeof Element.prototype.mozMatchesSelector)n=function(f,a){return f.mozMatchesSelector(a)};else if("undefined"!=typeof Element.prototype.msMatchesSelector)n=function(f,a){return f.msMatchesSelector(a)};else if("undefined"!=typeof Element.prototype.oMatchesSelector)n=function(f,a){return f.oMatchesSelector(a)};else{if("function"===
typeof jQuery||"function"===typeof Zepto)n=function(f,a){return $(f).is(a)};"undefined"===typeof n&&(n=Sizzle.matchesSelector)}var v=/(\[[^\]]+\])/g,A=/(#[^\s\+>~\.\[:]+)/g,z=/(\.[^\s\+>~\.\[:]+)/g,t=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,m=/(:[\w-]+\([^\)]*\))/gi,E=/(:[^\s\+>~\.\[:]+)/g,g=/([^\s\+>~\.\[:]+)/g})();
"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.drawSvg=function(l,w,n,v,A){canvg(this.canvas,l,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:w,offsetY:n,scaleWidth:v,scaleHeight:A})});
function RGBColor(l){this.ok=!1;"#"==l.charAt(0)&&(l=l.substr(1,6));l=l.replace(/ /g,"");l=l.toLowerCase();var w={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",
darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",
gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",
lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",
oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",
slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},n;for(n in w)l==n&&(l=w[n]);var v=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(l){return[parseInt(l[1]),parseInt(l[2]),parseInt(l[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,
example:["#00ff00","336699"],process:function(l){return[parseInt(l[1],16),parseInt(l[2],16),parseInt(l[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(l){return[parseInt(l[1]+l[1],16),parseInt(l[2]+l[2],16),parseInt(l[3]+l[3],16)]}}];for(n=0;n<v.length;n++){var A=v[n].process,z=v[n].re.exec(l);z&&(channels=A(z),this.r=channels[0],this.g=channels[1],this.b=channels[2],this.ok=!0)}this.r=0>this.r||isNaN(this.r)?0:255<this.r?255:this.r;this.g=0>this.g||isNaN(this.g)?0:
255<this.g?255:this.g;this.b=0>this.b||isNaN(this.b)?0:255<this.b?255:this.b;this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"};this.toHex=function(){var l=this.r.toString(16),m=this.g.toString(16),n=this.b.toString(16);1==l.length&&(l="0"+l);1==m.length&&(m="0"+m);1==n.length&&(n="0"+n);return"#"+l+m+n};this.getHelpXML=function(){for(var l=[],m=0;m<v.length;m++)for(var n=v[m].example,g=0;g<n.length;g++)l[l.length]=n[g];for(var f in w)l[l.length]=f;n=document.createElement("ul");
n.setAttribute("id","rgbcolor-examples");for(m=0;m<l.length;m++)try{var a=document.createElement("li"),x=new RGBColor(l[m]),c=document.createElement("div");c.style.cssText="margin: 3px; border: 1px solid black; background:"+x.toHex()+"; color:"+x.toHex();c.appendChild(document.createTextNode("test"));var b=document.createTextNode(" "+l[m]+" -> "+x.toRGB()+" -> "+x.toHex());a.appendChild(c);a.appendChild(b);n.appendChild(a)}catch(e){}return n}}
var mul_table=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,
278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,
271,269,267,265,263,261,259],shg_table=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function premultiplyAlpha(l){var w=l.data;l=l.width*l.height*4;for(var n=0;n<l;n+=4){var v=w[n+3]/255;w[n]*=v;w[n+1]*=v;w[n+2]*=v}}
function unpremultiplyAlpha(l){var w=l.data;l=l.width*l.height*4;for(var n=0;n<l;n+=4){var v=w[n+3];0!=v&&(v=255/v,w[n]*=v,w[n+1]*=v,w[n+2]*=v)}}function stackBlurImage(l,w,n,v){l=document.getElementById(l);var A=l.naturalWidth,z=l.naturalHeight,t=document.getElementById(w);t.style.width=A+"px";t.style.height=z+"px";t.width=A;t.height=z;t=t.getContext("2d");t.clearRect(0,0,A,z);t.drawImage(l,0,0);isNaN(n)||1>n||(v?stackBlurCanvasRGBA(w,0,0,A,z,n):stackBlurCanvasRGB(w,0,0,A,z,n))}
function stackBlurCanvasRGBA(l,w,n,v,A,z){if(!(isNaN(z)||1>z)){z|=0;l=document.getElementById(l).getContext("2d");try{try{var t=l.getImageData(w,n,v,A)}catch(S){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"),t=l.getImageData(w,n,v,A)}catch(T){throw alert("Cannot access local image"),Error("unable to access local image data: "+T);}}}catch(S){throw alert("Cannot access image"),Error("unable to access image data: "+S);}premultiplyAlpha(t);var m=t.data,E,g,f,a,x,c,b,e,
d,q,k,h,p,y,F;var C=z+z+1;var J=v-1,M=A-1,r=z+1,K=r*(r+1)/2,O=new BlurStack,u=O;for(g=1;g<C;g++)if(u=u.next=new BlurStack,g==r)var P=u;u.next=O;var L=f=0;var G=mul_table[z],H=shg_table[z];for(E=0;E<A;E++){var I=e=d=q=a=x=c=b=0;var B=r*(k=m[f]);var N=r*(h=m[f+1]);var Q=r*(p=m[f+2]);var R=r*(y=m[f+3]);a+=K*k;x+=K*h;c+=K*p;b+=K*y;u=O;for(g=0;g<r;g++)u.r=k,u.g=h,u.b=p,u.a=y,u=u.next;for(g=1;g<r;g++){var D=f+((J<g?J:g)<<2);a+=(u.r=k=m[D])*(F=r-g);x+=(u.g=h=m[D+1])*F;c+=(u.b=p=m[D+2])*F;b+=(u.a=y=m[D+3])*
F;I+=k;e+=h;d+=p;q+=y;u=u.next}g=O;u=P;for(C=0;C<v;C++)m[f]=a*G>>H,m[f+1]=x*G>>H,m[f+2]=c*G>>H,m[f+3]=b*G>>H,a-=B,x-=N,c-=Q,b-=R,B-=g.r,N-=g.g,Q-=g.b,R-=g.a,D=L+((D=C+z+1)<J?D:J)<<2,I+=g.r=m[D],e+=g.g=m[D+1],d+=g.b=m[D+2],q+=g.a=m[D+3],a+=I,x+=e,c+=d,b+=q,g=g.next,B+=k=u.r,N+=h=u.g,Q+=p=u.b,R+=y=u.a,I-=k,e-=h,d-=p,q-=y,u=u.next,f+=4;L+=v}for(C=0;C<v;C++){e=d=q=I=x=c=b=a=0;f=C<<2;B=r*(k=m[f]);N=r*(h=m[f+1]);Q=r*(p=m[f+2]);R=r*(y=m[f+3]);a+=K*k;x+=K*h;c+=K*p;b+=K*y;u=O;for(g=0;g<r;g++)u.r=k,u.g=h,u.b=
p,u.a=y,u=u.next;D=v;for(g=1;g<=z;g++)f=D+C<<2,a+=(u.r=k=m[f])*(F=r-g),x+=(u.g=h=m[f+1])*F,c+=(u.b=p=m[f+2])*F,b+=(u.a=y=m[f+3])*F,I+=k,e+=h,d+=p,q+=y,u=u.next,g<M&&(D+=v);f=C;g=O;u=P;for(E=0;E<A;E++)D=f<<2,m[D]=a*G>>H,m[D+1]=x*G>>H,m[D+2]=c*G>>H,m[D+3]=b*G>>H,a-=B,x-=N,c-=Q,b-=R,B-=g.r,N-=g.g,Q-=g.b,R-=g.a,D=C+((D=E+r)<M?D:M)*v<<2,a+=I+=g.r=m[D],x+=e+=g.g=m[D+1],c+=d+=g.b=m[D+2],b+=q+=g.a=m[D+3],g=g.next,B+=k=u.r,N+=h=u.g,Q+=p=u.b,R+=y=u.a,I-=k,e-=h,d-=p,q-=y,u=u.next,f+=v}unpremultiplyAlpha(t);
l.putImageData(t,w,n)}}
function stackBlurCanvasRGB(l,w,n,v,A,z){if(!(isNaN(z)||1>z)){z|=0;l=document.getElementById(l).getContext("2d");try{try{var t=l.getImageData(w,n,v,A)}catch(N){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"),t=l.getImageData(w,n,v,A)}catch(Q){throw alert("Cannot access local image"),Error("unable to access local image data: "+Q);}}}catch(N){throw alert("Cannot access image"),Error("unable to access image data: "+N);}var m=t.data,E,g,f,a,x,c,b,e,d,q,k,h;var p=z+z+1;var y=
v-1,F=A-1,C=z+1,J=C*(C+1)/2,M=new BlurStack,r=M;for(g=1;g<p;g++)if(r=r.next=new BlurStack,g==C)var K=r;r.next=M;var O=f=0;var u=mul_table[z],P=shg_table[z];for(E=0;E<A;E++){var L=b=e=a=x=c=0;var G=C*(d=m[f]);var H=C*(q=m[f+1]);var I=C*(k=m[f+2]);a+=J*d;x+=J*q;c+=J*k;r=M;for(g=0;g<C;g++)r.r=d,r.g=q,r.b=k,r=r.next;for(g=1;g<C;g++){var B=f+((y<g?y:g)<<2);a+=(r.r=d=m[B])*(h=C-g);x+=(r.g=q=m[B+1])*h;c+=(r.b=k=m[B+2])*h;L+=d;b+=q;e+=k;r=r.next}g=M;r=K;for(p=0;p<v;p++)m[f]=a*u>>P,m[f+1]=x*u>>P,m[f+2]=c*
u>>P,a-=G,x-=H,c-=I,G-=g.r,H-=g.g,I-=g.b,B=O+((B=p+z+1)<y?B:y)<<2,L+=g.r=m[B],b+=g.g=m[B+1],e+=g.b=m[B+2],a+=L,x+=b,c+=e,g=g.next,G+=d=r.r,H+=q=r.g,I+=k=r.b,L-=d,b-=q,e-=k,r=r.next,f+=4;O+=v}for(p=0;p<v;p++){b=e=L=x=c=a=0;f=p<<2;G=C*(d=m[f]);H=C*(q=m[f+1]);I=C*(k=m[f+2]);a+=J*d;x+=J*q;c+=J*k;r=M;for(g=0;g<C;g++)r.r=d,r.g=q,r.b=k,r=r.next;B=v;for(g=1;g<=z;g++)f=B+p<<2,a+=(r.r=d=m[f])*(h=C-g),x+=(r.g=q=m[f+1])*h,c+=(r.b=k=m[f+2])*h,L+=d,b+=q,e+=k,r=r.next,g<F&&(B+=v);f=p;g=M;r=K;for(E=0;E<A;E++)B=f<<
2,m[B]=a*u>>P,m[B+1]=x*u>>P,m[B+2]=c*u>>P,a-=G,x-=H,c-=I,G-=g.r,H-=g.g,I-=g.b,B=p+((B=E+C)<F?B:F)*v<<2,a+=L+=g.r=m[B],x+=b+=g.g=m[B+1],c+=e+=g.b=m[B+2],g=g.next,G+=d=r.r,H+=q=r.g,I+=k=r.b,L-=d,b-=q,e-=k,r=r.next,f+=v}l.putImageData(t,w,n)}}function BlurStack(){this.a=this.b=this.g=this.r=0;this.next=null}
(function(l){var w=l.Uint8Array,n=(l=l.HTMLCanvasElement)&&l.prototype,v=/\s*;\s*base64\s*(?:;|$)/i,A="toDataURL",z;w&&(z=new w([62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51]));!l||n.toBlob&&n.toBlobHD||(n.toBlob||(n.toBlob=function(l,m){m||(m="image/png");if(this.mozGetAsFile)l(this.mozGetAsFile("canvas",m));else if(this.msToBlob&&
/^\s*image\/png\s*(?:$|;)/i.test(m))l(this.msToBlob());else{var n=Array.prototype.slice.call(arguments,1),g=this[A].apply(this,n),f=g.indexOf(",");n=g.substring(f+1);g=v.test(g.substring(0,f));if(Blob.fake){var a=new Blob;a.encoding=g?"base64":"URI";a.data=n;a.size=n.length}else if(w)if(g){a=Blob;g=n.length;f=new w(g/4*3|0);for(var t=0,c=0,b=[0,0],e=0,d=0,q,k;g--;)k=n.charCodeAt(t++),q=z[k-43],255!==q&&void 0!==q&&(b[1]=b[0],b[0]=k,d=d<<6|q,e++,4===e&&(f[c++]=d>>>16,61!==b[1]&&(f[c++]=d>>>8),61!==
b[0]&&(f[c++]=d),e=0));a=new a([f],{type:m})}else a=new Blob([decodeURIComponent(n)],{type:m});l(a)}}),n.toBlobHD=!n.toBlobHD&&n.toDataURLHD?function(){A="toDataURLHD";var l=this.toBlob();A="toDataURL";return l}:n.toBlob)})("undefined"!==typeof self&&self||"undefined"!==typeof window&&window||this.content||this);
var saveAs=saveAs||function(l){if(!("undefined"===typeof l||"undefined"!==typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var w=l.document.createElementNS("http://www.w3.org/1999/xhtml","a"),n="download"in w,v=/constructor/i.test(l.HTMLElement)||l.safari,A=/CriOS\/[\d]+/.test(navigator.userAgent),z=function(f){(l.setImmediate||l.setTimeout)(function(){throw f;},0)},t=function(f){setTimeout(function(){"string"===typeof f?(l.URL||l.webkitURL||l).revokeObjectURL(f):f.remove()},4E4)},m=function(f){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(f.type)?
new Blob([String.fromCharCode(65279),f],{type:f.type}):f},E=function(f,a,g){g||(f=m(f));var c=this,b="application/octet-stream"===f.type,e=function(){var a=["writestart","progress","write","writeend"];a=[].concat(a);for(var b=a.length;b--;){var d=c["on"+a[b]];if("function"===typeof d)try{d.call(c,c)}catch(p){z(p)}}};c.readyState=c.INIT;if(n){var d=(l.URL||l.webkitURL||l).createObjectURL(f);setTimeout(function(){w.href=d;w.download=a;var b=new MouseEvent("click");w.dispatchEvent(b);e();t(d);c.readyState=
c.DONE})}else(function(){if((A||b&&v)&&l.FileReader){var a=new FileReader;a.onloadend=function(){var b=A?a.result:a.result.replace(/^data:[^;]*;/,"data:attachment/file;");l.open(b,"_blank")||(l.location.href=b);c.readyState=c.DONE;e()};a.readAsDataURL(f);c.readyState=c.INIT}else d||(d=(l.URL||l.webkitURL||l).createObjectURL(f)),b?l.location.href=d:l.open(d,"_blank")||(l.location.href=d),c.readyState=c.DONE,e(),t(d)})()},g=E.prototype;if("undefined"!==typeof navigator&&navigator.msSaveOrOpenBlob)return function(f,
a,g){a=a||f.name||"download";g||(f=m(f));return navigator.msSaveOrOpenBlob(f,a)};g.abort=function(){};g.readyState=g.INIT=0;g.WRITING=1;g.DONE=2;g.error=g.onwritestart=g.onprogress=g.onwrite=g.onabort=g.onerror=g.onwriteend=null;return function(f,a,g){return new E(f,a||f.name||"download",g)}}}("undefined"!==typeof self&&self||"undefined"!==typeof window&&window||this.content);
"undefined"!==typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!==typeof define&&null!==define&&null!==define.amd&&define("FileSaver.js",function(){return saveAs});
/* 
 * This is the function which relies on all the above. 
 * By A Waterhouse
 * License: Just use it
 */
function svgToPNG(id, filename)
{
	if(filename==null)
		filename = 'structure.png';
	var DOMURL = window.URL || window.webkitURL || window;
	var xml = $('<div>').append($('[id='+id+'] svg:eq(0)').clone()).html();
	xml = xml.replace('xmlns="http://www.w3.org/2000/svg" xmlns:NS1="" NS1:xmlns:xlink="http://www.w3.org/1999/xlink"','');
	var blob = new Blob([xml], {type: 'image/svg+xml'});
	var url = DOMURL.createObjectURL(blob);
	$('body').append('<canvas display="none" id="tmpcanvas"></canvas>');
	canvg('tmpcanvas', url, {
			renderCallback:function()
			{
				var c=document.getElementById("tmpcanvas");
				c.toBlob(function(blob) {	
					saveAs(blob, filename);
				});
				c.parentNode.removeChild(c);
			}
		});	
}